package com.wyy.controller;

import com.wyy.pojo.model.ArticleQueryCriteria;
import com.wyy.response.CommonReturnType;
import com.wyy.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @program: gytcb
 * @author: 吴磊
 * @create: 2021-06-08 11:56
 */
@RestController
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    /**
     * 获取所有的文章
     *
     * @param articleQueryCriteria
     * @return
     */
    @RequestMapping(value = "/getAllArticle", method = RequestMethod.POST)
    public CommonReturnType getAllArticle(@RequestBody ArticleQueryCriteria articleQueryCriteria) {
        Map<String, Object> allArticle = articleService.getAllArticle(articleQueryCriteria);
        return CommonReturnType.create(allArticle);
    }

    /**
     * 根据文章ID删除文章
     *
     * @param articleId
     * @return
     */
    @RequestMapping(value = "/deleteArticleVyId", method = RequestMethod.POST)
    public CommonReturnType deleteArticleById(@RequestBody String articleId) {
        articleService.deleteArticleByArticleId(articleId);
        return CommonReturnType.create(null);
    }
}
